#!/bin/bash
# Backend setup script for CMDB

echo "=========================================="
echo "CMDB Backend Setup"
echo "=========================================="

# Create virtual environment
echo "Creating virtual environment..."
python3 -m venv .venv

# Activate virtual environment
echo "Activating virtual environment..."
. .venv/bin/activate

# Upgrade pip
echo "Upgrading pip..."
pip install --upgrade pip

# Install dependencies
echo "Installing Python dependencies..."
pip install -r backend/requirements.txt

# Run migrations
echo "Running database migrations..."
python backend/manage.py makemigrations
python backend/manage.py migrate

# Create superuser prompt
echo ""
echo "=========================================="
echo "Setup complete!"
echo "=========================================="
echo ""
echo "To create a superuser (admin), run:"
echo "  python backend/manage.py createsuperuser"
echo ""
echo "To start the backend server, run:"
echo "  ./start_backend.sh"
echo ""
